import $api from "./api";
var wx = require("weixin-js-sdk");
const AES = require("crypto-js/aes");
const CryptoJS = require("crypto-js");

var root = process.env.VUE_APP_MAIN;
var root1 = process.env.VUE_APP_MAIN1;
var root2 = process.env.VUE_APP_MAIN2;
var operator = process.env.VUE_APP_DO;
var aesKey = process.env.VUE_APP_AESKEY;
var iv = process.env.VUE_APP_IV;
var appId = process.env.VUE_APP_APPID;
// htmlFontSize();
let deviceType='-1'; // 手机机型
let channelCode='-1';// 推广渠道码
let PhoneVleus= '';  // 手机信息
let deviceNo = '1';   // 设备号


// ----------------------



// -----------------------

let Util = {
  getUrlKey: getUrlKey,
  getCustomUrlKey:getCustomUrlKey,
  // 全局参数
  root: root,
  root1:root1,
  root2:root2,
};


// 获取url链接参数
function getUrlKey(name) {
  return (
    decodeURIComponent(
      (new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
        location.href
      ) || [, ""])[1].replace(/\+/g, "%20")
    ) || null
  );
}
// 获取自定义url链接参数
function getCustomUrlKey(url,name) {
  return (
    decodeURIComponent(
      (new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(url) || [
        ,
        ""
      ])[1].replace(/\+/g, "%20")
    ) || null
  );
}

//本地储存
function setSaveVlues(key,vlues) {
  let userAgentObj = navigator.userAgent;
  if (userAgentObj.match(/Android/i)) {
    window.control.setSaveVlues(key, vlues);
  } else if (userAgentObj.match(/iPhone/i)) {
    localStorage.setItem(key, vlues);
  }
}


export default Util;
